package com.mybatis.demo3;

import java.io.Reader;
import java.util.List;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class MainApp {
	private static ApplicationContext ctx;
	static	{
		ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
	}
	/**
	 * mybatis 与 spring集成
	 */
	public void testDemo(){
		UserOperation mapper = (UserOperation)ctx.getBean("userMapper");
		System.out.println(mapper.getUserArticles(1));
	}
	
	public void testDemo2(){
		UserService userService = (UserService)ctx.getBean("userService");
		userService.getList("com.mybatis.demo3.UserOperation.getUserArticles");
	}
	public static void main(String[] args) {
		//new MainApp().testDemo2();
		MybatisDao dao = (MybatisDao)ctx.getBean("dao");
		System.out.println(dao.queryForList("getUserArticles"));
		//baseService baseService = (baseService)ctx.getBean("baseService");
		//System.out.println(baseService);
		UserService userService = (UserService)ctx.getBean("userService");
		System.out.println(userService);
		System.out.println(userService.getList("com.mybatis.demo3.UserOperation.getUserArticles"));
		System.out.println(userService.getList("getUserArticles"));
	}
}
